package cn.edu.scau.cmi.liangguan.comprehensive.singletonClient;

import javafx.fxml.FXML;

import javafx.scene.control.Button;
import javafx.stage.Stage;

import java.io.IOException;

import application.Main;
import cn.edu.scau.cmi.liangguan.client.AbstractFactoryMode;
import cn.edu.scau.cmi.liangguan.client.AdapterClient;
import cn.edu.scau.cmi.liangguan.client.CompositeClient;
import cn.edu.scau.cmi.liangguan.client.FactoryMode;
import cn.edu.scau.cmi.liangguan.client.MultipletonClient;
import cn.edu.scau.cmi.liangguan.client.SimpleFactory;
import javafx.event.ActionEvent;

public class MainClientController {
	@FXML
	private Button singleBtn;
	@FXML
	private Button multipleBtn;
	@FXML
	private Button simpleFactoryBtn;
	@FXML
	private Button factoryMethodBtn;
	@FXML
	private Button abstractFactoryBtn;
	@FXML
	private Button adapterBtn;
	@FXML
	private Button compositeBtn;
	@FXML
	private Button hibernateBtn;
	@FXML
	private Button springBtn;

	// Event Listener on Button[#singleBtn].onAction
	@FXML
	public void singleEvent(ActionEvent event) {
		// TODO Autogenerated
		Main singleton = new Main();
	 	singleton.start(new Stage());
	}
	// Event Listener on Button[#multipleBtn].onAction
	@FXML
	public void multipleEvent(ActionEvent event) {
		// TODO Autogenerated
		MultipletonClient multipleton = new MultipletonClient();
    	multipleton.start(new Stage());
	}
	// Event Listener on Button[#simpleFactoryBtn].onAction
	@FXML
	public void simpleFactoryEvent(ActionEvent event) {
		// TODO Autogenerated
		SimpleFactory simpleFactory = new SimpleFactory();
		simpleFactory.start(new Stage());
	}
	// Event Listener on Button[#factoryMethodBtn].onAction
	@FXML
	public void factoryMethodEvent(ActionEvent event) {
		// TODO Autogenerated
		FactoryMode factoryMode = new FactoryMode();
    	factoryMode.start(new Stage());
	}
	// Event Listener on Button[#abstractFactoryBtn].onAction
	@FXML
	public void abstractFactoryEvent(ActionEvent event) {
		// TODO Autogenerated
		AbstractFactoryMode abstractFactory = new AbstractFactoryMode();
    	abstractFactory.start(new Stage());
	}
	// Event Listener on Button[#adapterBtn].onAction
	@FXML
	public void adapterEvent(ActionEvent event) {
		// TODO Autogenerated
		AdapterClient adapter = new AdapterClient();
    	adapter.start(new Stage());
	}
	// Event Listener on Button[#compositeBtn].onAction
	@FXML
	public void compositeEvent(ActionEvent event) {
		// TODO Autogenerated
		CompositeClient composite = new CompositeClient();
    	composite.start(new Stage());
	}
	// Event Listener on Button[#hibernateBtn].onAction
	@FXML
	public void hibernateEvent(ActionEvent event) {
		// TODO Autogenerated
		Runtime runtime = Runtime.getRuntime();
    	try {
			runtime.exec("rundll32 url.dll,FileProtocolHandler " + "http://47.107.80.14:8080/201627010412/hibernate/DBClient.jsp");
			runtime.exec("rundll32 url.dll,FileProtocolHandler " + "http://47.107.80.14:8080/201627010412/hibernate/student.jsp");
			runtime.exec("rundll32 url.dll,FileProtocolHandler " + "http://47.107.80.14:8080/201627010412/hibernate/teacher.jsp");			
		} catch (IOException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
}
